<template>
  <el-dialog title="修改项目信息" :visible.sync="dialogEditorVisible" width="50%" :before-close="handleClose">
    <el-form class="demo-form-inline" ref="form" :model="currentRow" label-width="100px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目名称">
            <el-input v-model="currentRow.pName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目编码">
            <el-input v-model="currentRow.pCode"></el-input>
          </el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目简称">
            <el-input v-model="currentRow.pJc"></el-input>
          </el-form-item></el-col>
        <el-col :span="12">
          <el-form-item label="项目金额">
            <el-input v-model="currentRow.pMoney"></el-input>
          </el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目地址">
            <el-input v-model="currentRow.pAddr"></el-input>
          </el-form-item></el-col>
        <el-col :span="12">
          <el-form-item label="项目工期(月)">
            <el-input v-model="currentRow.pUration"></el-input>
          </el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="开工时间">
            <el-date-picker type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"
              v-model="currentRow.startTime"></el-date-picker>
          </el-form-item></el-col>
        <el-col :span="12">
          <el-form-item label="终止时间">
            <el-date-picker type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"
              v-model="currentRow.endTime"></el-date-picker>
          </el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="隧道数量">
            <el-input v-model="currentRow.tunnelNum"></el-input>
          </el-form-item></el-col>
        <el-col :span="12">
          <el-form-item label="项目状态" >
            <el-radio v-model="currentRow.pStatus" label="1">施工中</el-radio>
            <el-radio v-model="currentRow.pStatus" label="2">已完成</el-radio>
          </el-form-item>
        </el-col>
      </el-row>










      <!-- <el-form-item label="备注">
        <el-input v-model="currentRow.bz"></el-input>
      </el-form-item> -->
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogEditorVisible = false">取 消</el-button>
      <el-button type="primary" @click="create">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import api from '../../../api'
import qs from 'qs'

export default {
  data() {
    return {
      dialogEditorVisible: false,
      eTypeList: [],
      tunnelList: [],
      fileList: [],
      currentRow: {}
    }
  },
  props: {
    flag: {
      type: Boolean,
      default: false
    }
  },
  mounted() {
    this.$bus.$on('onShowEditorProject', (row) => {
      this.dialogEditorVisible = true
      this.currentRow = row
    })
    this.kaiwa
  },
  methods: {
    kaiwa() {
      api
        .eTypeFindByAll()
        .then((res) => {
          if (res.data.code == 2001) {
            this.eTypeList = res.data.data
          }
        })
        .catch((err) => {
          console.log(err)
        })
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then((_) => {
          done()
        })
        .catch((_) => { })
    },
    create() {
      api
        .proAdminupdate(qs.stringify(this.currentRow))
        .then((res) => {
          if (res.data.code == 2001) {
            this.$message({
              type: 'success',
              message: '更新成功!'
            })
            this.dialogEditorVisible = false
            this.$bus.$emit('onRefreshProAdmin', true)
          } else {
            this.$message({
              type: 'fail',
              message: '更新失败!'
            })
            this.dialogVisible = false
            this.$bus.$emit('onRefresh', true)
          }
        })
        .catch((err) => { })
    },
    onSubmit() {
      console.log('submit!')
    }
  }
}
</script>

<style scoped >
.avatar-uploader .el-upload {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  width: 50px !important;
  height: 50px !important;
  font-size: 28px;
  line-height: 50px !important;
  color: #8c939d;
  text-align: center;
}

.avatar {
  display: block;
  width: 50px !important;
  height: 50px !important;
}

.imgbeforepad {
  padding-top: 0px !important;
}

.avatar-uploader .el-icon-plus {
  margin: 15px !important;
}
</style>